const express = require("express");
const route = express.Router(); // 实例化路由对象
const Xunfei = require("./NLP/xunfei/index");

// ws.on("close", function (e) {
// console.log("连接关闭");
// });

route.get("/", function (req, res, next) {
  res.render("index", { title: "Express" });
});

route.get("/demo", (req, res) => {
  let apiRes = {
    code: 0,
    msg: "成功",
    data: "请求通过",
  };
  res.send(apiRes);
});

route.ws("/mySocketUrl", (ws, req) => {
  ws.on("message", function (msg) {
    Xunfei.init(ws, msg);
    // Xunfei.send(msg);
  });
});
module.exports = route; // 暴露出去方便管理
